package request

import (
	"fox/common"
	"fox/models"
	"reflect"
)

type UserRole struct {
	Paging
}

type SaveUserRole struct {
	UserId int64 `json:"userId" binding:"required"`
	RoleId int64 `json:"roleId" binding:"required"`
}

type UpdateUserRole struct {
	ID     int64 `json:"id" binding:"required"`
	UserId int64 `json:"userId" binding:"required"`
	RoleId int64 `json:"roleId" binding:"required"`
	Status int   `json:"status" binding:"omitempty,min=-1,max=1"`
}

func ValidateUserRoleSortFile(filed string) bool {
	var (
		userRole *models.UserRole
		ele      reflect.Type
	)

	userRole = &models.UserRole{}
	ele = reflect.TypeOf(userRole).Elem()
	for i := 0; i < ele.NumField(); i++ {
		var tagSetting = common.ParseTagSetting(ele.Field(i).Tag.Get("gorm"), ";")
		if tagSetting["COLUMN"] == filed {
			return true
		}
	}
	return false
}
